package org.goldfish.client_demo.client_demo.service;

import org.goldfish.distributed_framework.api.RpcMethod;
import org.goldfish.distributed_framework.api.Service;
import redis.clients.jedis.Jedis;
//import redis.clients.jedis.ScanParams;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;


public class Query extends BasicRedisService implements Service {


    @RpcMethod
    public String query(String name) {
        return getConnection().get(name);
    }

    @RpcMethod
    public Map<String, String> queryAll() {
        Map<String, String> result = new HashMap<>();
        Jedis conn = getConnection();
        Set<String> keys = conn.keys("*");
        keys.forEach(
                key -> result.put(key, conn.get(key))
        );
        System.out.println(result);
        return result;

    }
}
